/**
 * 
 */
package com.simple.user;

import java.util.List;

import com.jfinal.plugin.activerecord.Model;
import com.simplecms.util.MD5Util;


/**
 * 系统用户
 * @author zhanxj
 *
 */
@SuppressWarnings("serial")
public class User extends Model<User>{
	public static final User dao = new User();
	public static final String ID="id";
	public static final String USERNAME="username";
	public static final String PASSWORD="password";
	public static final String SEX="sex";
	public static final String PHONE="phone";
	public static final String EMAIL="email";
	public static final String ISONLINE="isOnline";
	public static final String LASTLOGINTIME="lastLoginTime";
	public List<User> queryUserByNameAndPassword(String username,String password){
		String pwd = MD5Util.getInstance().getMD5ByPrivateKey(password);
		StringBuilder sql = new StringBuilder();
		sql.append("SELECT * FROM user WHERE username='");
		sql.append(username);
		sql.append("' AND password='");
		sql.append(pwd);
		sql.append("'");
		return User.dao.find(sql.toString());
	}
	public List<User> queryUserByName(String username){
		StringBuilder sql = new StringBuilder();
		sql.append("SELECT * FROM user WHERE username='");
		sql.append(username);
		sql.append("'");
		return User.dao.find(sql.toString());
	}
}
